package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account          string `gorm:"type:varchar(30);comment:'账号'"`
	Password         string `gorm:"type:char(32);comment:'密码'"`
	Salt             string `gorm:"type:char(6);comment:盐"`
	Email            string `gorm:"type:varchar(50);comment:邮箱 "`
	Status           int    `gorm:"tinyint(1);comment:状态:1-正常,2禁用"`
	MemberStatus     int    `gorm:"tinyint(1);default:1;comment:viper状态:0 不是会员,1是会员"`
	MemberStatusTime int64  `gorm:"tinyint;default:0;comment:会员有效期"`
}

func (u *User) GetUserByUsername(DB *gorm.DB) error {
	return DB.Where("account =?", u.Account).Limit(1).Find(&u).Error

}

func (u *User) Createuser(DB *gorm.DB) error {
	return DB.Create(&u).Error
}
